View Javadoc
1 /*** 2 * Copyright 2003, 2004, 2005. CodeStreet LLC. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 package com.codestreet.selector.parser; 16 17 import java.util.Map; 18 19 /*** 20 * Class to represent the <tt>bool</tt> equality operator. Immutable. 21 * 22 * @author Jawaid Hakim. 23 */ 24 class OpBoolEQ implements IExpressionBool 25 { 26 /*** 27 * Ctor. 28 * 29 * @param lhs 30 * LHS of the equality. 31 * @param rhs 32 * RHS of the equality. 33 */ 34 public OpBoolEQ(final IExpression lhs, final IExpression rhs) 35 { 36 lhs_ = lhs; 37 rhs_ = rhs; 38 } 39 40 public Object eval(final Map identifiers) 41 { 42 Object oLhs = lhs_.eval(identifiers); 43 if (!(oLhs instanceof Boolean)) 44 return Result.RESULT_UNKNOWN; 45 boolean lhs = ((Boolean) oLhs).booleanValue(); 46 47 Object oRhs = rhs_.eval(identifiers); 48 if (!(oRhs instanceof Boolean)) 49 return Result.RESULT_UNKNOWN; 50 boolean rhs = ((Boolean) oRhs).booleanValue(); 51 52 if (lhs == rhs) 53 return Result.RESULT_TRUE; 54 else 55 return Result.RESULT_FALSE; 56 } 57 58 public Object eval(final IValueProvider provider, final Object corr) 59 { 60 Object oLhs = lhs_.eval(provider, corr); 61 if (!(oLhs instanceof Boolean)) 62 return Result.RESULT_UNKNOWN; 63 boolean lhs = ((Boolean) oLhs).booleanValue(); 64 65 Object oRhs = rhs_.eval(provider, corr); 66 if (!(oRhs instanceof Boolean)) 67 return Result.RESULT_UNKNOWN; 68 boolean rhs = ((Boolean) oRhs).booleanValue(); 69 70 if (lhs == rhs) 71 return Result.RESULT_TRUE; 72 else 73 return Result.RESULT_FALSE; 74 } 75 76 public String toString() 77 { 78 return lhs_.toString() + " = " + rhs_.toString(); 79 } 80 81 private final IExpression lhs_; 82 83 private final IExpression rhs_; 84 85 }

This page was automatically generated by Maven